<!doctype html>
<html lang="en">
<head>
    <title>登录到ranter水果店</title>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="css/bootstrap.css">
    <style>
        .form-group-lg .form-control{
            height: 30px;
            font-size: 12px;
        }

    </style>
</head>
<body>
<div class="container">
    <div class="row">
        <h2>商品列表管理</h2>
        <form class="form-horizontal"  method="post" action="#" enctype="multipart/form-data">
            <h3>添加商品</h3>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品名称</label>
                <div class="col-sm-2">
                    <input name="spName" class="form-control" type="text" id="formGroupInputLarge" placeholder="请输入商品名称">
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品描述</label>
                <div class="col-sm-10">
                    <textarea name="spMiaoshu" class="form-control" rows="3" id="liuyan" placeholder="请输入商品描述"></textarea>
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品标价</label>
                <div class="col-sm-2">
                    <input name="jiage" class="form-control" type="text" id="formGroupInputSmall" placeholder="请输入商品标价">
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品图片</label>
                <input name="img" type="file">
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-success">提交商品信息</button>
                </div>
            </div>
        </form>
        <form class="form-horizontal">
            <h3>删除商品</h3>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品名称</label>
                <div class="col-sm-2">
                    <input name="spName_1" class="form-control" type="text" id="formGroupInputLarge" placeholder="请输入商品名称">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button id="shanchu" type="button" class="btn btn-success">确定删除</button>
                </div>
            </div>
        </form>
        <form class="form-horizontal" id="form" method="post" action="/updata" enctype="multipart/form-data">
            <h3>查询商品信息</h3>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品名称</label>
                <div class="col-sm-2">
                    <input name="spName_2" class="form-control" type="text" id="formGroupInputLarge" placeholder="请输入商品名称进行查询">

                </div>
                <div class="col-sm-2">
                    <button id="chaxun" type="button" class="btn btn-success">查询</button>
                </div>
            </div>
            <h3>更改商品信息</h3>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品描述</label>
                <div class="col-sm-10">
                    <textarea class="form-control" rows="3" name="spMiaoshu_1" id="liuyan" placeholder="请输入商品描述"></textarea>
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品标价</label>
                <div class="col-sm-2">
                    <input class="form-control" type="text" name="biaojia" id="formGroupInputSmall" placeholder="请输入商品标价">
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品图片源地址</label>
                <div class="col-sm-2">
                    <input class="form-control" type="text" name="image_1" id="formGroupInputSmall" placeholder="">
                </div>
            </div>
            <div class="form-group form-group-lg">
                <label class="col-sm-2 control-label" for="formGroupInputLarge">商品图片</label>
                <input name="img_1" type="file">
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button id="tijiao" type="submit" class="btn btn-success">提交商品信息</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="js/jquery-3.2.0.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>-->
<script src="js/bootstrap.js"></script>
<script>
    $("#shanchu").click(function(){
        console.log(111);
        $.post('/shanchu',{"spName": $("[name='spName_1']").val()},function(result){
            if(result === "1"){
                alert("删除成功");
            }else{
                alert("删除失败");
            }
        })
    })
    $("#chaxun").click(function(){
        $.get('/chaxun',{"spName":$("[name='spName_2']").val()},function(result){
            console.log(result);
            $("[name='spMiaoshu_1']").text(result[0].spMiaoshu || []);
            console.log(result[0].jiage)
            $("[name='biaojia']").val(result[0].jiage || []);
            console.log(result[0].image)
            $("[name='image_1']").val(result[0].image || []);
        })
    })
    /*$("#tijiao").click(function(){
       $("#form").attr("action",'/updata');
        $("#form").submit();
    })*/
</script>
</body>
</html>